﻿#ifndef HNRJITDIALOGPART_H
#define HNRJITDIALOGPART_H

HWND GetSafeHwnd() const
{
	return m_hWnd;
}

// Message Functions

LRESULT SendMessage(UINT message, WPARAM wParam = 0, LPARAM lParam = 0) throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::SendMessage(m_hWnd, message, wParam, lParam);
}

BOOL PostMessage(UINT message, WPARAM wParam = 0, LPARAM lParam = 0) throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::PostMessage(m_hWnd, message, wParam, lParam);
}

// Window Text Functions

BOOL SetWindowText(LPCTSTR lpszString) throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::SetWindowText(m_hWnd, lpszString);
}

// Window Size and Position Functions

BOOL MoveWindow(int x, int y, int nWidth, int nHeight, BOOL bRepaint = TRUE) throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::MoveWindow(m_hWnd, x, y, nWidth, nHeight, bRepaint);
}

BOOL MoveWindow(LPCRECT lpRect, BOOL bRepaint = TRUE) throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::MoveWindow(m_hWnd, lpRect->left, lpRect->top, lpRect->right - lpRect->left, lpRect->bottom - lpRect->top, bRepaint);
}

BOOL SetWindowPos(HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags) throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::SetWindowPos(m_hWnd, hWndInsertAfter, x, y, cx, cy, nFlags);
}

BOOL SetWindowPos(HWND hWndInsertAfter, LPCRECT lpRect, UINT nFlags) throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::SetWindowPos(m_hWnd, hWndInsertAfter, lpRect->left, lpRect->top, lpRect->right - lpRect->left, lpRect->bottom - lpRect->top, nFlags);
}

BOOL BringWindowToTop() throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::BringWindowToTop(m_hWnd);
}

BOOL GetWindowRect(LPRECT lpRect) const throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::GetWindowRect(m_hWnd, lpRect);
}

BOOL GetClientRect(LPRECT lpRect) const throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::GetClientRect(m_hWnd, lpRect);
}

// Coordinate Mapping Functions

BOOL ClientToScreen(LPPOINT lpPoint) const throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::ClientToScreen(m_hWnd, lpPoint);
}

BOOL ClientToScreen(LPRECT lpRect) const throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	if (!::ClientToScreen(m_hWnd, (LPPOINT)lpRect))
		return FALSE;
	return ::ClientToScreen(m_hWnd, ((LPPOINT)lpRect) + 1);
}

BOOL ScreenToClient(LPPOINT lpPoint) const throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::ScreenToClient(m_hWnd, lpPoint);
}

BOOL ScreenToClient(LPRECT lpRect) const throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	if (!::ScreenToClient(m_hWnd, (LPPOINT)lpRect))
		return FALSE;
	return ::ScreenToClient(m_hWnd, ((LPPOINT)lpRect) + 1);
}

// Update and Painting Functions

HDC BeginPaint(LPPAINTSTRUCT lpPaint) throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::BeginPaint(m_hWnd, lpPaint);
}

void EndPaint(LPPAINTSTRUCT lpPaint) throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	::EndPaint(m_hWnd, lpPaint);
}

HDC GetDC() throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::GetDC(m_hWnd);
}

HDC GetWindowDC() throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::GetWindowDC(m_hWnd);
}

int ReleaseDC(HDC hDC) throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::ReleaseDC(m_hWnd, hDC);
}

BOOL UpdateWindow() throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::UpdateWindow(m_hWnd);
}

BOOL Invalidate(BOOL bErase = TRUE) throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::InvalidateRect(m_hWnd, NULL, bErase);
}

BOOL InvalidateRect(LPCRECT lpRect, BOOL bErase = TRUE) throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::InvalidateRect(m_hWnd, lpRect, bErase);
}

BOOL ValidateRect(LPCRECT lpRect) throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::ValidateRect(m_hWnd, lpRect);
}

BOOL ShowWindow(int nCmdShow) throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::ShowWindow(m_hWnd, nCmdShow);
}

BOOL IsWindowVisible() const throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::IsWindowVisible(m_hWnd);
}

// Timer Functions

UINT_PTR SetTimer(UINT_PTR nIDEvent, UINT nElapse, void (CALLBACK* lpfnTimer)(HWND, UINT, UINT_PTR, DWORD) = NULL) throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::SetTimer(m_hWnd, nIDEvent, nElapse, (TIMERPROC)lpfnTimer);
}

BOOL KillTimer(UINT_PTR nIDEvent) throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::KillTimer(m_hWnd, nIDEvent);
}

// Window State Functions

BOOL IsWindowEnabled() const throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::IsWindowEnabled(m_hWnd);
}

BOOL EnableWindow(BOOL bEnable = TRUE) throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::EnableWindow(m_hWnd, bEnable);
}

HWND SetActiveWindow() throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::SetActiveWindow(m_hWnd);
}

HWND SetCapture() throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::SetCapture(m_hWnd);
}

HWND SetFocus() throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::SetFocus(m_hWnd);
}

HWND GetParent() const throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::GetParent(m_hWnd);
}

HWND SetParent(HWND hWndNewParent) throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::SetParent(m_hWnd, hWndNewParent);
}

DWORD GetWindowThreadID() throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	return ::GetWindowThreadProcessId(m_hWnd, NULL);
}

DWORD GetWindowProcessID() throw()
{
	ATLASSERT(::IsWindow(m_hWnd));
	DWORD dwProcessID;
	::GetWindowThreadProcessId(m_hWnd, &dwProcessID);
	return dwProcessID;
}

BOOL IsWindow() const throw()
{
	return ::IsWindow(m_hWnd);
}

#endif // HNRJITDIALOGPART_H